LastSelectable
interface LastSelectable
A parent element marked as LastSelectable will cache the last selected element when a popup or other overlay is rendered, and return to that selection when the popup/overlay is removed.
Author
fzzyhmstrs
Since
0.2.0
Samples
import me.fzzyhmstrs.fzzy_config.screen.LastSelectable
import me.fzzyhmstrs.fzzy_config.screen.widget.PopupWidget
import me.fzzyhmstrs.fzzy_config.screen.widget.internal.CustomButtonWidget
import net.minecraft.client.MinecraftClient
import net.minecraft.client.gui.Element
import net.minecraft.client.gui.ParentElement
import net.minecraft.client.gui.widget.TextWidget
import net.minecraft.text.Text
import net.minecraft.util.Identifier
fun main() {
//sampleStart
//simple stub example of a LastSelectable, passing its focused element back and forth with its lastSelected cache
abstract class ExampleLastSelectable: ParentElement, LastSelectable {
override var lastSelected: Element? = null
override fun pushLast() {
lastSelected = focused
}
override fun popLast() {
focused = lastSelected
}
}
//sampleEnd
}